#include <vector>
using namespace std;
/*
 * @lc app=leetcode.cn id=27 lang=cpp
 *
 * [27] 移除元素
 */

// @lc code=start
class Solution {
public:
    int removeElement(vector<int>& nums, int val) {
        int p = 0, q = 0;
        while (q < nums.size()) {
            if (nums[q] == val) q++;
            else {
                nums[p] = nums[q];
                p++; q++;
            }
        }
        return p;
    }
};
// @lc code=end

